home *** CD-ROM | disk | FTP | other *** search
/ Shareware for Windows / Trust Shareware CD.iso / winshare / filemgt / inityme / inityme.mnu < prev   
Encoding:
MarxMenu script  |  1994-07-14  |  17.4 KB  |  774 lines

  1. Comment
  2. ==========================================================
  3.  
  4. Computer Tyme IniTyme * Copyright 1993-94 by Marc Perkel
  5. All Rights Reserved
  6.  
  7. Computer Tyme * 411 North Sherman, Suite 300 * Springfield Mo. 65802
  8. (800) 548-5353 Sales * (417) 866-1222 Voice * (417) 866-1665 Data/Fax
  9.  
  10. IniTyme is a Windows *.INI file manipulator. It is designed to assist the
  11. network administrator who has to maintain INI files for many users.
  12.  
  13. USAGE: INITYME ChangeFile IniFile
  14.  
  15. Example:
  16.   INITYME CHANGE.INI SYSTEM.INI
  17.  
  18. ==========================================================
  19. EndComment
  20.  
  21. ;------ Create Variables
  22.  
  23. var
  24.   Orig
  25.   UOrig
  26.   KOrig
  27.   Changes
  28.   UChanges
  29.   NameIndex
  30.   BlockStartIndex
  31.   BlockEndIndex
  32.   CurrentSection
  33.   ThisSection
  34.   SectionStart
  35.   SectionEnd
  36.   SubFind
  37.   SubReplace
  38.   SubFindG
  39.   SubReplaceG
  40.   GroupSection
  41.   GroupMode
  42.   Sections
  43.   InsertPos
  44.   Log
  45.   Logging
  46.   LogFileName
  47.   LogGroup
  48.   BackName
  49.   NoBackup
  50.   RestoreMode
  51.   TestMode
  52.  
  53. var
  54.   IfArray
  55.   Stack
  56.   GotoList
  57.   IfLine
  58.   GroupList
  59.   ParenLevel
  60.  
  61. Main
  62.  
  63. ;======================= P R O C E D U R E S ===========================
  64.  
  65. Comment
  66. ================================================
  67.  
  68. The file is read into the array Orig. It is then processed and a
  69. parallel array UOrig is created. The lines in UOrig are upper case with
  70. extra spaces and comments removed and are more suitable for searching
  71. and comparing.
  72.  
  73. NameIndex contains a list of group headings. BlockStartIndex contains a list
  74. of line numbers that groups start. BlockEndIndex contains a list og line
  75. numbers where groups end. That way when I search I know what range of
  76. line numbers to start and end at.
  77.  
  78. ================================================
  79. EndComment
  80.  
  81.  
  82. Procedure IndexFile
  83. var LastTextLine
  84.    HashLevel = 2
  85.    UOrig = Orig
  86.    Loop UOrig
  87.       LoopVal = CleanIniLine(LoopVal)
  88.       if LoopVal StartsWith '['
  89.  
  90.          ;-- Process Header
  91.  
  92.          ThisSection = LoopVal
  93.          GroupSection = ThisSection = '[GROUPS]'
  94.          CurrentSection = CurrentSection + 1
  95.  
  96.          AppendArray(NameIndex,LoopVal)
  97.          AppendArray(BlockStartIndex,succ(LoopIndex))
  98.          if CurrentSection > 1
  99.             AppendArray(BlockEndIndex,LastTextLine)
  100.          endif
  101.       else
  102.          if LoopVal > ''
  103.             LastTextLine = LoopIndex
  104.             KOrig[LoopIndex] = KeyString(LoopVal)
  105.          endif
  106.       endif
  107.    EndLoop
  108.    Sections = CurrentSection
  109.    CurrentSection = 0
  110.    if Sections > 0
  111.       AppendArray(BlockEndIndex,LastTextLine)
  112.    endif
  113. EndProc
  114.  
  115.  
  116. Procedure KeyString (St)
  117. var KeyWord
  118.    KeyWord = LeftOfEqual(St)
  119.    if Hash(KeyWord + ThisSection)
  120.       Return St
  121.    endif
  122.    GroupMode = False
  123.    if GroupSection
  124.       if St StartsWith 'GROUP'
  125.          GroupMode = True
  126.          KeyWord = 'GROUP=' + FilePart(RightOfEqual(St))
  127.       endif
  128.    endif
  129.    Return KeyWord
  130. EndProc
  131.  
  132.  
  133. ;----- When adding or deleting the BlockStartIndex must be updated
  134.  
  135. Procedure AdjustLineIndex (Line, Adj)
  136.    Loop BlockStartIndex
  137.       if Line <= LoopVal
  138.          LoopVal = LoopVal + Adj
  139.       endif
  140.    EndLoop
  141.    Loop BlockEndIndex
  142.       if Line <= LoopVal
  143.          LoopVal = LoopVal + Adj
  144.       endif
  145.    EndLoop
  146. EndProc
  147.  
  148.  
  149. Procedure LogEvent ($St)
  150.    if not Logging then Return
  151.    if LogGroup <> ThisSection
  152.       if LogGroup <> ''
  153.          AppendArray(Log,'')
  154.       endif
  155.       AppendArray(Log,ThisSection)
  156.       LogGroup = ThisSection
  157.    endif
  158.    AppendArray(Log,St)
  159. EndProc
  160.  
  161.  
  162. Procedure DelLine (Line)
  163.    if Line = 0 then Return
  164.    LogEvent '  Deleted: ' Orig[Line]
  165.    Delete(Orig,Line,1)
  166.    Delete(UOrig,Line,1)
  167.    Delete(KOrig,Line,1)
  168.    AdjustLineIndex(Line,-1)
  169. EndProc
  170.  
  171.  
  172. Procedure InsertLine (St,Line)
  173.    ArrayInsert(Orig,Line,1)
  174.    ArrayInsert(UOrig,Line,1)
  175.    ArrayInsert(KOrig,Line,1)
  176.  
  177.    Orig[Line] = St
  178.    UOrig[Line] = CleanIniLine(St)
  179.    KOrig[Line] = KeYString(UOrig[Line])
  180. EndProc
  181.  
  182.  
  183. ;----- Change a line, 0 for line number adds line
  184.  
  185. Procedure ChangeOrAddLine (St,Line)
  186. var Original
  187.    if Line = 0
  188.  
  189.       ;- new line
  190.  
  191.       if CurrentSection > 0
  192.  
  193.          ;- Determine Insert Position
  194.  
  195.          if InsertPos = 0
  196.             Line = BlockEndIndex[CurrentSection] + 1
  197.          else
  198.             Line = InsertPos
  199.             InsertPos = 0
  200.          endif
  201.  
  202.          if GroupMode
  203.             St = 'Group' + Str(NextGroup) + '=' + RightOfEqual(St)
  204.          endif
  205.  
  206.          InsertLine(St,Line)
  207.  
  208.          AdjustLineIndex(Line - 1,1)
  209.          LogEvent '    Added: ' St
  210.       endif
  211.    else
  212.  
  213.       ;- change line
  214.  
  215.       Original = Orig[Line]
  216.       if InsertPos > 0
  217.  
  218.          ;- move the line
  219.  
  220.          Delete(Orig,Line,1)
  221.          Delete(UOrig,Line,1)
  222.          Delete(KOrig,Line,1)
  223.          Line = InsertPos
  224.  
  225.          InsertLine(St,Line)
  226.          InsertPos = 0
  227.       endif
  228.  
  229.       if GroupMode
  230.          St = LeftOfEqual(Orig[Line]) + RightOfEqual(St)
  231.       endif
  232.  
  233.       if St <> Original
  234.          LogEvent '  Changed: ' Original ' to ' St
  235.          Orig[Line] = St
  236.          UOrig[Line] = CleanIniLine(St)
  237.          KOrig[Line] = KeyString(UOrig[Line])
  238.       endif
  239.    endif
  240. EndProc
  241.  
  242.  
  243. Procedure AddSection (St)
  244. var Lines Proc
  245.    Proc = CleanIniLine(St)
  246.  
  247.    ;- Add a blank line
  248.  
  249.    AppendArray(Orig,'')
  250.    AppendArray(UOrig,'')
  251.    AppendArray(KOrig,'')
  252.  
  253.    ;- Add CurrentSection header
  254.  
  255.    AppendArray(Orig,St)
  256.    AppendArray(UOrig,Proc)
  257.    AppendArray(KOrig,Proc)
  258.  
  259.    ;- Update Indexes
  260.  
  261.    Lines = NumberOfElements(UOrig)
  262.    AppendArray(NameIndex,Proc)
  263.    AppendArray(BlockStartIndex,Lines)
  264.    AppendArray(BlockEndIndex,Lines)
  265.  
  266.    ;- Make new CurrentSection the current CurrentSection
  267.  
  268.    CurrentSection = NumberOfElements(NameIndex)
  269.  
  270.    if Logging
  271.       LogGroup = UpperCase(St)
  272.       AppendArray(Log,'')
  273.       LogEvent LogGroup ' -*- Section Added'
  274.    endif
  275.  
  276. EndProc
  277.  
  278.  
  279. Procedure DelSection (St)
  280. var S E D
  281.    FindSection(St)
  282.    if CurrentSection = 0 then Return
  283.  
  284.    S = BlockStartIndex[CurrentSection] - 1
  285.    E = BlockEndIndex[CurrentSection]
  286.    D = E - S + 1
  287.  
  288.    delete(Orig,S,D)
  289.    delete(UOrig,S,D)
  290.    delete(KOrig,S,D)
  291.  
  292.    delete(NameIndex,CurrentSection,1)
  293.    delete(BlockStartIndex,CurrentSection,1)
  294.    delete(BlockEndIndex,CurrentSection,1)
  295.    AdjustLineIndex(S,0 - D)
  296.    CurrentSection = 0
  297.  
  298.    if Logging
  299.       LogGroup = ''
  300.       AppendArray(Log,'')
  301.       LogEvent UpperCase(St) ' -*- Section Deleted'
  302.       AppendArray(Log,'')
  303.    endif
  304.  
  305. EndProc
  306.  
  307.  
  308. Procedure FindSection (St)
  309.    CurrentSection = PosInList(St,NameIndex)
  310.    if CurrentSection = 0
  311.       ThisSection = ''
  312.       GroupSection = False
  313.       SectionStart = 0
  314.       SectionEnd = 0
  315.    else
  316.       ThisSection = St
  317.       SectionStart = BlockStartIndex[CurrentSection]
  318.       SectionEnd   = BlockEndIndex[CurrentSection]
  319.       GroupSection = ThisSection = '[GROUPS]'
  320.    endif
  321. EndProc
  322.  
  323.  
  324. Procedure FindLine (St)
  325.    Return PosInList(KeyString(St),KOrig,SectionStart,SectionEnd)
  326. EndProc
  327.  
  328.  
  329. ;----- Replaces text in block from the list of substitute text.
  330.  
  331. Procedure ApplySubstBlock (SubF,SubR,S,E)
  332. var P St
  333.    if NumberOfElements(SubF) = 0 then Return
  334.    while S <= E
  335.       Loop SubF
  336.  
  337.          repeat
  338.             P = Pos(LoopVal,UOrig[S])
  339.             if P > 0
  340.                St = Orig[S]
  341.                delete(St,P,Length(LoopVal))
  342.                insert(SubR[LoopIndex],St,P)
  343.                ChangeOrAddLine(St,S)
  344.             endif
  345.          until P = 0
  346.  
  347.       EndLoop
  348.       S = S + 1
  349.    endwhile
  350.    dispose(SubFind)
  351.    dispose(SubReplace)
  352. EndProc
  353.  
  354.  
  355. Procedure ApplySubst
  356.    if CurrentSection = 0 then Return
  357.    ApplySubstBlock(SubFind,SubReplace,BlockStartIndex[CurrentSection],BlockEndIndex[CurrentSection])
  358.    ApplySubstBlock(SubFindG,SubReplaceG,BlockStartIndex[CurrentSection],BlockEndIndex[CurrentSection])
  359. EndProc
  360.  
  361.  
  362. Procedure NextGroup
  363. var X S E St Match
  364.    X = 1
  365.    repeat
  366.       S = BlockStartIndex[CurrentSection]
  367.       E = BlockEndIndex[CurrentSection]
  368.       Match = False
  369.       while (S <= E) and not Match
  370.          St = 'GROUP' + Str(X)
  371.          Match = pos(St,UOrig[S]) > 0
  372.          S = S + 1
  373.       endwhile
  374.       if not Match then Return X
  375.       X = X + 1
  376.    until False
  377. EndProc
  378.  
  379.  
  380. Procedure RemoveExtraBlankLines
  381. var Tmp
  382.    Trim(Orig)
  383.    Tmp = Orig
  384.    dispose Orig
  385.    Loop Tmp
  386.       if (LoopVal > '') or (Tmp[LoopIndex + 1] > '')
  387.          AppendArray(Orig,LoopVal)
  388.       endif
  389.    EndLoop
  390. EndProc
  391.  
  392.  
  393. Procedure AddItem (Line)
  394. var St List New UNew NewLine Next UNext
  395.    St = UOrig[Line]
  396.    New = RightOfEqual(Changes[LoopIndex])
  397.    UNew = RightOfEqual(UChanges[LoopIndex])
  398.    St = RightOfEqual(St)
  399.    NewLine = Orig[Line]
  400.    while St > ''
  401.       AppendArray(List,NextWord(St))
  402.    endwhile
  403.    while UNew > ''
  404.       Next = NextWord(New);
  405.       UNext = NextWord(UNew);
  406.       if PosInList(UNext,List) = 0
  407.          NewLine = NewLine + ' ' + Next
  408.       endif
  409.    endwhile
  410.    ChangeOrAddLine(NewLine,Line)
  411. EndProc
  412.  
  413.  
  414. Procedure DelItem (Line)
  415. var St List New UNew NewLine Next UNext P
  416.    St = UOrig[Line]
  417.    UNew = RightOfEqual(UChanges[LoopIndex])
  418.    St = St + ' '
  419.    NewLine = Orig[Line]
  420.    while UNew > ''
  421.       UNext = NextWord(UNew);
  422.       P = pos(UNext + ' ',St)
  423.       if P > 0
  424.          delete(St,P,length(UNext) + 1)
  425.          delete(NewLine,P,length(UNext) + 1)
  426.       endif
  427.    endwhile
  428.    TrimTrail(NewLine)
  429.    ChangeOrAddLine(NewLine,Line)
  430. EndProc
  431.  
  432.  
  433. Procedure ChangeFile
  434. var St New Line Tmp FirstWord RestOfLine X Y
  435.    Loop Changes
  436.       New = LoopVal
  437.       St = UChanges[LoopIndex]
  438.       if St > ''
  439.  
  440.          RestOfLine = St
  441.          FirstWord = NextWord(RestOfLine)
  442.  
  443.          if Hash(FirstWord)
  444.             St = RestOfLine
  445.             Tmp = NextWord(New)
  446.  
  447.             if CurrentSection = 0
  448.                if FirstWord = 'TESTMODE'
  449.                   TestMode
  450.  
  451.                elseif FirstWord = 'LOG'
  452.                   LogFileName = RestOfLine
  453.                   if LogFileName = ''
  454.                      LogFileName = ForceExtension(BackName,'LOG')
  455.                   endif
  456.                   Logging
  457.  
  458.                elseif FirstWord = 'NOBACKUP'
  459.                   NoBackup = True
  460.  
  461.                endif
  462.             endif
  463.  
  464.             if FirstWord = 'DEL'
  465.                if RestOfLine StartsWith '['
  466.                   ApplySubst
  467.                   DelSection(RestOfLine)
  468.                else
  469.                   DelLine(FindLine(RestOfLine))
  470.                endif
  471.  
  472.             elseif FirstWord = 'ADD'
  473.                Line = FindLine(St)
  474.                if Line = 0
  475.                   ChangeOrAddLine(New,0)
  476.                endif
  477.  
  478.             elseif FirstWord = 'CHANGE'
  479.                Line = FindLine(St)
  480.                if Line > 0
  481.                   ChangeOrAddLine(New,Line)
  482.                endif
  483.  
  484.             elseif FirstWord = 'ADDVALUE'
  485.                Line = FindLine(St)
  486.                if Line > 0
  487.                   X = Value(RightOfEqual(New)) + Value(RightOfEqual(UOrig[Line]))
  488.                   Tmp = LeftOfEqual(New)
  489.                   ChangeOrAddLine(Tmp + Str(X),Line)
  490.                endif
  491.  
  492.             elseif FirstWord = 'ADDITEM'
  493.                Line = FindLine(St)
  494.                if Line > 0
  495.                   AddItem(Line,St)
  496.                else
  497.                   ChangeOrAddLine(New,0)
  498.                endif
  499.  
  500.             elseif FirstWord = 'DELITEM'
  501.                Line = FindLine(St)
  502.                if Line > 0
  503.                   DelItem(Line,St)
  504.                endif
  505.  
  506.             elseif FirstWord = 'SUBST'
  507.                if CurrentSection = 0
  508.                   AppendArray(SubFindG,CleanIniLine(NextWord(St)))
  509.                   AppendArray(SubReplaceG,NextWord(St))
  510.                else
  511.                   AppendArray(SubFind,CleanIniLine(NextWord(St)))
  512.                   AppendArray(SubReplace,NextWord(St))
  513.                endif
  514.  
  515.             elseif FirstWord = 'BEFORE'
  516.                InsertPos = FindLine(St)
  517.  
  518.             elseif FirstWord = 'AFTER'
  519.                InsertPos = succ(FindLine(St))
  520.  
  521.             elseif FirstWord = 'FIRST'
  522.                InsertPos = BlockStartIndex[CurrentSection]
  523.  
  524.             endif
  525.  
  526.          else
  527.  
  528.             ;- Process Sections
  529.  
  530.             if St StartsWith '['
  531.  
  532.                ;- New Group
  533.  
  534.                ApplySubst
  535.                FindSection(St)
  536.                if CurrentSection = 0
  537.                   AddSection(LoopVal)
  538.                endif
  539.  
  540.             else
  541.  
  542.                ;- Process Lines
  543.  
  544.                ChangeOrAddLine(New,Findline(St))
  545.  
  546.             endif
  547.  
  548.          endif
  549.       endif
  550.       IfLine = IfArray[LoopIndex]
  551.       Interpret
  552.       if NumberOfElements Stack <> 0
  553.          Error ('Too Many Parameters!',LoopIndex)
  554.       endif
  555.    EndLoop
  556.    ApplySubst
  557.    ApplySubstBlock(SubFindG,SubReplaceG,1,NumberOfElements(Orig))
  558. EndProc
  559.  
  560.  
  561. Procedure Help
  562. var Help HelpFile
  563.    HelpFile = ExistOnPath 'INITYME.HLP'
  564.    if HelpFile = ''
  565.       Writeln
  566.       Writeln 'IniTyme * Copyright 1993 by Marc Perkel'
  567.  
  568.       Include 'ADDRESS.INC'
  569.  
  570.       Writeln 'Missing file INITYME.HLP'
  571.    else
  572.       BoxHeader ' Viewing ' + HelpFile + ' '
  573.       DrawBox 1 1 ScreenWidth ScreenHeight
  574.       ViewTextFile(HelpFile)
  575.    endif
  576.    ExitMenu
  577. EndProc
  578.  
  579.  
  580. Procedure Beg
  581. var Jessica
  582.    BoxHeader ' * Shameless Beg Screen * '
  583.    DrawBox 10 8 61 7
  584.    Writeln
  585.    WriteCenter '* IniTyme Evaluation Copy *'
  586.    Writeln
  587.    WriteCenter 'Please remember to register this software.'
  588.    Writeln
  589.    if Timer and 1 = 0
  590.       Jessica = Now - TimeOf('1-17-80') / SecondsInDay / 365 + 2
  591.       WriteCenter 'I have a ' Jessica ' year old daughter who wants to go shopping.'
  592.    else
  593.       WriteCenter "I'd sure hate to have to find a real job."
  594.    endif
  595.    Wait 600
  596.    EraseTopWindow
  597.    ClearKbdBuffer
  598. EndProc
  599.  
  600.  
  601. Procedure Error (St,Line)
  602.    Writeln
  603.    if Line > 0
  604.       Writeln 'IniTyme Error in line ' Line
  605.       Writeln St
  606.    else
  607.       Writeln 'IniTyme Error: ' St
  608.    endif
  609.    ExitMenu
  610. EndProc
  611.  
  612.  
  613. ;----- INITYME.INC has the conditional logic.
  614.  
  615. Include 'INITYME.INC'
  616.  
  617.  
  618. Procedure AddIniExtension (Name)
  619.    Name = UpperCase(Name)
  620.    if pos('.',Name) > 0 then Return Name
  621.    Return ForceExtension(Name,'INI')
  622. EndProc
  623.  
  624.  
  625. Procedure Setup
  626.    BoxBorderColor Green Blue
  627.    BoxInsideColor White Blue
  628.    BoxHeaderColor Yellow Mag
  629.   ;Beg
  630.    RestoreMode = UpperCase(ParamStr(2)) = 'RESTORE'
  631.    if not RestoreMode
  632.       if (ParamStr(2) = '') or not ExistFile(AddIniExtension(ParamStr(2)))
  633.          Help
  634.       endif
  635.    endif
  636.    StandardIO
  637.    if NovConnection > 0
  638.       NovReadGroups(NovLoginName,GroupList)
  639.       SortArray(GroupList)
  640.    endif
  641.  
  642.    ;-- Duplicates List - Add your own duplicates here.
  643.  
  644.    HashLevel = 3
  645.    Hash('DEVICE=[386ENH]') = True
  646.  
  647.    ReadTextFile(AddIniExtension(ParamStr(2)),Changes)
  648.    Loop Changes
  649.       Trim(LoopVal)
  650.       LoopVal = EnvExpandString(LoopVal)
  651.    EndLoop
  652.    UChanges = Changes
  653.    Loop UChanges
  654.       LoopVal = CleanIniLine(LoopVal)
  655.  
  656.       if LoopVal StartsWith 'IF '
  657.          IfArray[LoopIndex] = LoopVal
  658.          LoopVal = ''
  659.          Changes[LoopIndex] = ''
  660.          PushStack(LoopIndex)
  661.  
  662.       elseif LoopVal = 'ENDIF'
  663.          LoopVal = ''
  664.          Changes[LoopIndex] = ''
  665.          GotoList[PopStack] = LoopIndex
  666.  
  667.       elseif LoopVal = 'ELSE'
  668.          LoopVal = ''
  669.          Changes[LoopIndex] = ''
  670.          IfArray[LoopIndex] = 'GOTO'
  671.          GotoList[PopStack] = LoopIndex
  672.          PushStack(LoopIndex)
  673.  
  674.       endif
  675.  
  676.    EndLoop
  677.  
  678.    ;-- if you forgot an Endif then the stack contains values.
  679.  
  680.    if NumberOfElements Stack <> 0
  681.       Error ('MisMatched Conditionals!',0)
  682.    endif
  683.  
  684.    HashLevel = 4
  685.    Hash('ADD') = True
  686.    Hash('ADDITEM') = True
  687.    Hash('ADDVALUE') = True
  688.    Hash('AFTER') = True
  689.    Hash('BEFORE') = True
  690.    Hash('CHANGE') = True
  691.    Hash('DEL') = True
  692.    Hash('DELITEM') = True
  693.    Hash('FIRST') = True
  694.    Hash('LOG') = True
  695.    Hash('NOBACKUP') = True
  696.    Hash('SUBST') = True
  697.    Hash('TESTMODE') = True
  698.  
  699.    SetupLibWords
  700. EndProc
  701.  
  702.  
  703. Procedure ResetVariables
  704.    dispose(NameIndex)
  705.    dispose(BlockStartIndex)
  706.    dispose(BlockEndIndex)
  707.    dispose(SubFind)
  708.    dispose(SubReplace)
  709.    dispose(SubFindG)
  710.    dispose(SubReplaceG)
  711.    dispose(Log)
  712.    LogGroup = ''
  713.    CurrentSection = 0
  714. EndProc
  715.  
  716.  
  717. Procedure ProcessFile (Name)
  718. var FileList MultiFile
  719.    Name = AddIniExtension(Name)
  720.    BackName = ForceExtension(Name,'BNI')
  721.    ReadTextFile(Name,Orig)
  722.    if NumberOfElements Orig > 0
  723.       if ExistFile(Orig[1])
  724.          MultiFile = True
  725.          FileList = Orig
  726.          Loop FileList
  727.             ProcessFile(LoopVal)
  728.          EndLoop
  729.       endif
  730.    endif
  731.    if not MultiFile
  732.       if RestoreMode
  733.          if ExistFile(BackName)
  734.             Writeln 'Restoring ' Name
  735.             DelFile(Name)
  736.             FileRename(BackName,Name)
  737.          else
  738.             Writeln BackName ' not Found!'
  739.          endif
  740.       else
  741.          ResetVariables
  742.          Write 'Converting: ' Name ' '
  743.          IndexFile
  744.          ChangeFile
  745.          RemoveExtraBlankLines
  746.  
  747.          if TestMode
  748.             WriteTextFile(BackName,Orig)
  749.          else
  750.             DelFile(BackName)
  751.             FileRename(Name,BackName)
  752.             WriteTextFile(Name,Orig)
  753.          endif
  754.  
  755.          if NoBackup
  756.             DelFile(BackName)
  757.          endif
  758.  
  759.          if Logging
  760.             Trim(Log)
  761.             WriteTextFile(LogFileName,Log)
  762.          endif
  763.  
  764.          Writeln 'Done!'
  765.       endif
  766.    endif
  767. EndProc
  768.  
  769.  
  770. Procedure Main
  771.    Setup
  772.    ProcessFile(ParamStr(3))
  773. EndProc
  774.